<?php

/**
 * This is the model class for table "{{hotel_room}}".
 *
 * The followings are the available columns in table '{{hotel_room}}':
 * @property integer $holr_id
 * @property string $holr_name
 * @property string $holr_bed_type
 * @property double $holr_size
 * @property string $holr_environment
 * @property double $holr_price_1
 * @property double $holr_price_2
 * @property string $holr_desc
 * @property string $holr_log
 */
class hotel_room extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return hotel_room the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{hotel_room}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('holr_name, holr_bed_type', 'required'),
			array('holr_size, holr_price_1, holr_price_2', 'numerical'),
			array('holr_name, holr_environment, holr_log', 'length', 'max'=>100),
			array('holr_bed_type', 'length', 'max'=>50),
			array('holr_desc', 'length', 'max'=>250),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('holr_id, holr_name, holr_bed_type, holr_size, holr_environment, holr_price_1, holr_price_2, holr_desc, holr_log', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'holr_id' => 'Holr',
			'holr_name' => '客房名称',
			'holr_bed_type' => '客房类型',
			'holr_size' => '客房大小',
			'holr_environment' => '客房景观',
			'holr_price_1' => '市场价',
			'holr_price_2' => '今日价',
			'holr_desc' => '客房描述',
			'holr_log' => '客房图片',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('holr_id',$this->holr_id);

		$criteria->compare('holr_name',$this->holr_name,true);

		$criteria->compare('holr_bed_type',$this->holr_bed_type,true);

		$criteria->compare('holr_size',$this->holr_size);

		$criteria->compare('holr_environment',$this->holr_environment,true);

		$criteria->compare('holr_price_1',$this->holr_price_1);

		$criteria->compare('holr_price_2',$this->holr_price_2);

		$criteria->compare('holr_desc',$this->holr_desc,true);

		$criteria->compare('holr_log',$this->holr_log,true);

		return new CActiveDataProvider('hotel_room', array(
			'criteria'=>$criteria,
		));
	}
}